/*
 * schedule.h
 *
 *  Created on: Apr 19, 2015
 *      Author: mxw
 */

#ifndef SCHEDULE_H_
#define SCHEDULE_H_

#define MAX_TASK_COUNT  (32)
#define IVALID_TASK_ID  (0xFF)

#define ST_TASK_INVALID     (0)
#define ST_TASK_IDLE        (1)
#define ST_TASK_SLEEP       (2)
#define ST_TASK_RUNNING     (3)


typedef struct {
    unsigned int regs[13];//r0-r12
    unsigned int sp_r13;
    unsigned int lr_r14;
    unsigned int pc_r15;
    unsigned int cpsr;
} task_regs;

typedef int (*TASK_ENTRY_FUN)();

typedef struct {
    task_regs r;
    TASK_ENTRY_FUN entry;
    unsigned char is_first_run;
    unsigned char priority;
    unsigned char st;
    unsigned short hunger_value;
} task_info;

typedef struct {
    task_info arr[MAX_TASK_COUNT];
} task_manager;


void init_task();
#endif /* SCHEDULE_H_ */
